// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database()
const _ = db.command

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  const data = {
    oName: event.oName, 
    head_pic:event.head_pic,
    partyContent: event.partyContent,
    partyImg: event.partyImg,
    partyOwner: event.partyOwner,
    partyTopic: event.partyTopic,
    partyType: event.partyType,
    location:event.location,
    pTime:parseInt(Date.now()/1000),
    lastReplyTime:parseInt(Date.now()/1000),
    pOverTime:event.pOverTime
  }
  let res = db.collection('partysInfo').add({
    data
  });
  console.log(res);

  return {
    res
  }
}